﻿@model Monocle.Models.AppViewModel
@{
    ViewBag.Title = "App";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script>
    $(function () {
        $("#sortable").sortable({
            placeholder: "ui-state-highlight",
            update: function (event, ui) {
                $('#PageOrder').val($(this).sortable('toArray').toString());
                var order = $(this).sortable('toArray').toString();
            }
        });
        $("#sortable").disableSelection();
    });
	</script>
@using (Html.BeginForm()) {
    @Html.ValidationSummary()
    @Html.HiddenFor(x => x.ID)
    @Html.HiddenFor(x => x.Version)
    @Html.HiddenFor(x => x.PageOrder)
    <div>
        <fieldset>
            <div class="editor-label">
                @Html.LabelFor(m => m.Name)
            </div>
            <div class="editor-field">
                @Html.EditorFor(m => m.Name)
                @Html.ValidationMessageFor(m => m.Name)
            </div>
             
           <div class="editor-label">
                 @Monocle.Resources.Monocle.PageViewModel
            </div>
            <div class="editor-field">
                <ul id="sortable">
                    @foreach (var item in Model.PageList)
                    {
	                    <li id="@item.ID" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>@Html.ActionLink(item.Name, "Edit", "Page", new { id = item.ID }, null) @Html.Monocle().ImageLinkButton("Delete", "Page", Url.Content("~/Content/images/GridIconDelete.png"), Monocle.Resources.Monocle.Generic_Delete, new { id = item.ID }, null)</li>
                    }
                </ul>
                @Html.Monocle().ImageLinkButtonWithText("Create", "Page", Url.Content("~/Content/images/GridIconAdd.png"), Monocle.Resources.Monocle.Generic_CreateNew, Monocle.Resources.Monocle.Generic_CreateNew, new { id = Model.ID }, null, null)
            </div>
        </fieldset>
        <div class="ButtomButtonPanel">
            <div class="MonocleStatus">@ViewBag.Status</div>
            @Html.Monocle().BasicCancelLink("About", "Home")
            @Html.Monocle().SaveButton()
        </div>
    </div>
}
